<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    /*选择价表自动补全*/
    autoCompleteDrug("drugName");
    function autoCompleteDrug(inputId){
        var drugCode = $("#drugCode").val();
        var url="${ctx}/drug/drugBuyStorage/autoComplete?drugCode="+drugCode;
        autoComplete(inputId,url,
            function(data){
                var rows = [];
                for(var i=0; i<data.length; i++){
                    rows[rows.length] = {
                        data:data[i],
                        value:data[i].id,
                        result:data[i].drug_name
                    };
                }
                return rows;
            },function(data, i, max){
                return data.drug_name+"|"+data.drug_code+"|"+data.package_spec+"|"+data.firm_name
            },function(event,data,formatted){
                $('#infoId').attr('value',data.id);
                $('#packageSpec').attr('value',data.package_spec);
              /*  $('#packageUnit').attr('value',data.package_unit);*/
                $('#drugSupplierCataId').attr('value',data.firm_id);
                $('#supplierName').attr('value',data.firm_name);
                $("#packageUnit option[value='"+data.package_unit+"']").attr("selected", true);
                $('#packageUnit').change();
            })
    }
</script>
    <!-- content wrapper -->
    <div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/drug/drugBuyStorage/index')">药品采购入库</a>
                </li>
                <li class="active">
                    <a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/drug/drugBuyStorage/drugBuyForm?id=${drugBuyPlan.id}')">
                        药品采购入库修改
                    </a>
                </li>

            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="col-lg-12">
                        <form:form id="inputForm" data-parsley-validate="" modelAttribute="drugBuyPlan" onsubmit="return formSaveLoad('mainCenterDiv','inputForm','${ctx}/drug/drugBuyStorage/saveDrugBuyPlan','${ctx}/drug/drugBuyStorage/index');" method="post" class="form-horizontal">
                            <form:hidden path="id"/>
                            <form:hidden path="infoId" id="infoId"/>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">采购序号：</label>
                                <div class="col-sm-6">
                                    <form:input path="purchaseOrder" id="purchaseOrder" htmlEscape="false" class="form-control" maxlength="32" readonly="true" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">药品编码：</label>
                                <div class="col-sm-6">
                                    <form:input path="drugCode" id="drugCode" htmlEscape="false" class="form-control" maxlength="32" readonly="true" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">药品名称：</label>
                                <div class="col-sm-6">
                                    <form:input path="drugName" id="drugName" htmlEscape="false" class="form-control"  maxlength="64" />
                                </div>
                                <span class="help-inline">双击可进行换药</span>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">包装规格：</label>
                                <div class="col-sm-6">
                                    <form:input path="packageSpec" id="packageSpec" htmlEscape="false" class="form-control"  maxlength="20" readonly="true"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">包装单位：</label>
                                <div class="col-sm-6">
                                    <form:select path="packageUnit" id="packageUnit" class="form-control">
                                        <form:option value="" label=""/>
                                        <form:options items="${fns:getDictList('SPEC_UNIT')}" itemLabel="label"
                                                      itemValue="value" htmlEscape="false"/>
                                    </form:select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">剂&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型：</label>
                                <div class="col-sm-6">
                                    <form:select path="drugNameDict.drugFrom" id="drugFrom" htmlEscape="false" class="form-control" data-parsley-required="true" disabled="true">
                                        <form:options items="${fns:getDictList('DRUG_FORM_DICT')}" itemLabel="label" itemValue="value" htmlEscape="false" />
                                    </form:select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">厂&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;家：</label>
                                <div class="col-sm-6">
                                    <form:hidden path="vedorName" id="drugSupplierCataId" />
                                    <form:input path="drugStock.drugInfo.drugSupplierCata.id" id="supplierName" htmlEscape="false" class="form-control"  maxlength="64" readonly="true"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                    <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('mainCenterDiv','${ctx}/drug/drugBuyStorage/index')">
                                </div>
                            </div>
                        </form:form>
                    </div>

                </div>
            </section>
        </div>
    </div>
